package com.reebake.ideal.crypto.handler;

import com.reebake.ideal.crypto.entity.SecretKeyEntity;
import com.reebake.ideal.crypto.core.SecretKeyService;
import com.reebake.ideal.crypto.properties.CryptoProperties;
import org.springframework.beans.factory.annotation.Autowired;

public class DefaultSecretKeyService implements SecretKeyService {
    @Autowired
    private CryptoProperties cryptoProperties;

    public SecretKeyEntity init() {
        SecretKeyEntity secretKeyEntity = new SecretKeyEntity();
        secretKeyEntity.setPrivateKey(cryptoProperties.getPrivateKey());
        secretKeyEntity.setPublicKey(cryptoProperties.getPublicKey());
        secretKeyEntity.setSecretKey(cryptoProperties.getSecretKey());
        return secretKeyEntity;
    }

    @Override
    public SecretKeyEntity queryRsa() {
        return init();
    }

    @Override
    public SecretKeyEntity queryByAppKey(String appKey) {
        SecretKeyEntity secretKeyEntity = init();
        secretKeyEntity.setAppKey(appKey);
        return secretKeyEntity;
    }
}
